//
// Created by shen on 2025/2/24.
//

#ifndef VIDEOEDIT_BASEPLAYER_H
#define VIDEOEDIT_BASEPLAYER_H
#include <SWorkStatus.h>
#include <thread>
#include <queue>
#include <condition_variable>
#include <mutex>
#include "SafeQueue.h"
extern "C" {
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
}
class BasePlayer {
public:
    explicit BasePlayer(FFStatus *ffstatus);

    virtual ~BasePlayer();

    virtual void OnFrameAvailable(AVFrame *frame)=0;

public:
    std::mutex codecMutex;
    std::mutex mutex;
    std::condition_variable cond;
    FFStatus *ffstatus= nullptr;
    AVRational timeBase;
    int fps;
    double  defaultDelayTime=0.04;
    //媒体文件的解码信息
    AVCodecParameters  *avCodecParameters= nullptr;

    SafeQueue *queue = nullptr;

    AVCodecContext *avCodecConext= nullptr;
    int duration;
    int streamIndex;
    std::thread m_Thread;
    virtual void play()=0;
//    static bool isPrepared;

};


#endif //VIDEOEDIT_BASEPLAYER_H
